﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zocono.WCS.Domain.PlcBytesObject
{
    public class QTScMessageWriteWcsActionBO : WriteByteObjectBase
    {

        /// <summary>
        /// 下发的任务号码
        /// </summary>
        public int ExecutedJobNum { get; set; }
        /// <summary>
        /// 双叉机型适用1：使用货叉1；2：使用货叉2；3：同时使用双货叉；
        /// </summary>
        public short ForkControl { get; set; }

        /// <summary>
        /// 下发的源排
        /// </summary>
        public short FromRow { get; set; }

        /// <summary>
        /// 下发的源列
        /// </summary>
        public short FromCol { get; set; }

        /// <summary>
        /// 下发的源层
        /// </summary>
        public short FromLayer { get; set; }

        /// <summary>
        /// 下发的源纵深
        /// </summary>
        public short FromDepth { get; set; }

        /// <summary>
        /// 下发的目标排
        /// </summary>
        public short ToRow { get; set; }

        /// <summary>
        /// 下发的目标列
        /// </summary>
        public short ToCol { get; set; }

        /// <summary>
        /// 下发的目标层
        /// </summary>
        public short ToLayer { get; set; }

        /// <summary>
        /// 下发的目标纵深
        /// </summary>
        public short ToDepth { get; set; }

        /// <summary>
        /// 1：取放（去源位置取货，目标位置放货）；2：取货（去源位置取货）；
        /// 3：放货（去目标位置放货）；4：行走（移动到源位置）；5：急停；
        /// 6：复位；7：任务删除； 8：灭火（去源位置灭火）；
        /// 9：取放+灭火（去源位置取货，目标位置放货，取货开始就开始灭火）；
        /// 10：取放+灭火（去源位置取货，目标位置放货，取货完成后开始灭火）；
        /// </summary>
        public short CommandMode { get; set; }
        /// <summary>
        /// 1：正常流程；2：消防流程；3：异形货物；
        /// </summary>
        public short SpecialTaskFlag { get; set; }
        /// <summary>
        /// 适用于双货叉1：屏蔽货叉1（货叉1故障时，屏蔽货叉1，使用货叉2执行任务）；2：屏蔽货叉2（货叉2故障时，屏蔽货叉2，使用货叉1执行任务）；
        /// </summary>
        public short ForkShield { get; set; }
        /// <summary>
        /// 心跳
        /// </summary>
        public short HeartBeat { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public short YuLiu1 { get; set; }

        public short YuLiu2 { get; set; }
        /// <summary>
        /// 1：任务下发完成，启动下发的任务（PLC读取后改为0）
        /// </summary>
        public short CompletionFlag { get; set; }

        public override byte[] Deserialize()
        {
            byte[] bytes = new byte[36];
            HelperByte.SetDIntAt(bytes, 0, ExecutedJobNum);
            HelperByte.SetIntAt(bytes, 4, ForkControl);
            HelperByte.SetIntAt(bytes, 6, FromRow);
            HelperByte.SetIntAt(bytes, 8, FromCol);
            HelperByte.SetIntAt(bytes, 10, FromLayer);
            HelperByte.SetIntAt(bytes, 12, FromDepth);
            HelperByte.SetIntAt(bytes, 14, ToRow);
            HelperByte.SetIntAt(bytes, 16, ToCol);
            HelperByte.SetIntAt(bytes, 18, ToLayer);
            HelperByte.SetIntAt(bytes, 20, ToDepth);
            HelperByte.SetIntAt(bytes, 22, CommandMode);
            HelperByte.SetIntAt(bytes, 24, SpecialTaskFlag);
            HelperByte.SetIntAt(bytes, 26, ForkShield);
            HelperByte.SetIntAt(bytes, 28, HeartBeat);
            HelperByte.SetIntAt(bytes, 30, YuLiu1);
            HelperByte.SetIntAt(bytes, 32, YuLiu2);
            HelperByte.SetIntAt(bytes, 34, CompletionFlag);
            return bytes;
        }
    }
}
